import java.util.Arrays;
//快速排序

public class quickSort {
    public void sort(int[] a,int start,int end){
        if(start>=end){
            return;
        }
        int privot = a[start];
        int i=start,j=end;
        while (i<j){
            while (i<j&&a[j]>=privot){
                j--;
            }
            a[i]=a[j];
            while (i<j&&a[i]<=privot){
                i++;
            }
            a[j]=a[i];
        }
        a[j] = privot;
        sort(a,start,i-1);
        sort(a,i+1,end);
    }
    public static void main(String[] args) {
        var main = new quickSort();
        int[] a = {5,2,1,3,7,6,8,8,7,6};
        main.sort(a,0,a.length-1);
        System.out.println(Arrays.toString(a));
    }
}
